/* eslint-disable eqeqeq *///忽略==的警告
import { meshLog, SPRemove, SPGet, SPSet } from "../config";
import { transIntToHex2Str } from "./dataUtils";
//判断是不是Sensor
export const isSensorDevice = (pid) => {
    let pids = transIntToHex2Str(pid)
    let mPids = ["1001", "1006", "1007", "1008", "100A", "100B", "100C", "100D", "100E", "100F", "1010", "1011", "1012", "1013", "1014", "1015", "101A", "101B", "101C", "1043", "1044"];
    return judgeContailPid(mPids, pids);
}
//判断是不是计量设备
export const isJiliangshebeiDevice = (pid) => {
    let pids = transIntToHex2Str(pid)
    let mPids = ["1002"];
    return judgeContailPid(mPids, pids);
}
//判断是不是电源
export const isPowerDevice = (pid) => {
    let pids = transIntToHex2Str(pid)
    let mPids = ["1003", "1016", "1017", "1018", "1019", "101F", "1020", "1021", "1022", "1023", "1024", "1025", "1026", "1027", "1028", "1029", "102A", "102B", "102C", "102D", "102E", "102F", "1030", "1031", "1032", "1033", "1034", "1035", "1036", "1037", "1038", "1039", "103A", "103B", "103C", "103D", "103E", "103F", "1040", "1041", "1042"];
    return judgeContailPid(mPids, pids);
}
//判断是不是gateway
export const isGatewayDevice = (pid) => {
    let pids = transIntToHex2Str(pid)
    let mPids = ["1004", "6666"];
    return judgeContailPid(mPids, pids);
}
//判断是不是remocon
export const isRemoconDevice = (pid) => {
    let pids = transIntToHex2Str(pid)
    let mPids = ["1005", "101D", "101E"];
    return judgeContailPid(mPids, pids);
}

//判断是不是dongle
export const isDongleDevice = (pid) => {
    let mPids = ["1009"];
    let pids = transIntToHex2Str(pid)
    return judgeContailPid(mPids, pids);
}

//判断有没有高亮图片（小眼睛）
export const isHightLightDevice = (pid) => {

    let pids = transIntToHex2Str(pid)
    let mPids = ["1001", "1006", "1007", "1008", "100A", "100B", "100C", "100D", "100E", "100F", "1010", "1011", "1012", "1013", "1014", "1015", "101A", "101B", "101C", "1043", "1044", "1002"];
    return judgeContailPid(mPids, pids);
}

//判断是不是未知设备
export const isNoneDevice = (pid) => {
    let mPids = ["0000"];
    let pids = transIntToHex2Str(pid)
    return judgeContailPid(mPids, pids);
}

//色温调光范围
export const getTempRange = (pid) => {
    if (dev22_45(pid)) {
        return ["2200", "4500"];
    } else if (dev30_50(pid)) {
        return ["3000", "5000"];
    } else if (isRGBDevice(pid)) {
        return ["2200", "6500"];
    } else {
        return ["2700", "6500"];
    }
}
//传一个组的编号进去来获取色温调光范围
// export const allAreaGetTempRange = (areaNo) => {
//     let deviceSetx = JSON.parse(SPGet("deviceSetx"));
//     //meshLog('areaNo', areaNo);
//     let temdata = ["3000", "4500"]
//     let dataNum = 0
//     for (let i = 0; i < deviceSetx.length; i++) {
//         if (deviceSetx[i].areaNo === areaNo) {
//             if (!isLightDevice(deviceSetx[i].pid)) {
//                 continue;
//             }
//             dataNum++;
//             let temdatadui = getTempRange(deviceSetx[i].pid)
//             if (temdatadui[0] <= temdata[0]) {
//                 temdata[0] = temdatadui[0]
//             }
//             if (temdatadui[1] >= temdata[1]) {
//                 temdata[1] = temdatadui[1]
//             }
//         }
//     }
//     if (dataNum == 0) {
//         temdata[0] = 2200
//         temdata[1] = 6500
//         return temdata
//     } else {
//         return temdata
//     }
// }
//传一个组的编号进去来获取色温调光范围
export const allSubgroupGetTempRange = (groupNo) => {
    let deviceSetx = JSON.parse(SPGet("deviceSetx"));
    let dataNum = 0
    let temdata = ["3000", "4500"]
    for (let i = 0; i < deviceSetx.length; i++) {
        if (deviceSetx[i].groupNo === groupNo) {
            dataNum++;
            let temdatadui = getTempRange(deviceSetx[i].pid)
            if (temdatadui[0] <= temdata[0]) {
                temdata[0] = temdatadui[0]
            }
            if (temdatadui[1] >= temdata[1]) {
                temdata[1] = temdatadui[1]
            }
        }
    }
    if (dataNum == 0) {
        temdata[0] = 2200
        temdata[1] = 6500
        return temdata
    } else {
        return temdata
    }
}
//rgb
export const isRGBDevice = (pid) => {
    let mPids = ["1027", "1028", "1029", "102B", "1032", "1033", "1035", "1037", "1038", "1039", "103A", "103B"];
    return judgeContailPid(mPids, pid);
}
//sensor

//支持SmartShift设备
export const isSmartshiftDevice = (pid) => {
    let mPids = ["1001", "1002", "1003", "1004", "1005", "1006", "1007", "1009", "100A", "100B", "1010", "1011", "1012", "1013",
        "1014", "1015", "1016", "101D", "101C", "101E", "101F", "1027", "1028", "1029", "102B", "102D", "1030", "1032", "1033", "1034",
        "1035", "1037", "1038", "1039", "103A", "103B", "104F", "1050"];
    return judgeContailPid(mPids, pid);
}
//灯丝灯色温范围
function dev22_45(pid) {
    let mPids = ["1010", "1011", "1012", "1013"];
    return judgeContailPid(mPids, pid);
}
//HID色温范围
function dev30_50(pid) {
    let mPids = ["1005", "1006", "1007"];
    return judgeContailPid(mPids, pid);
}
//外部调用的，主要是单灯和UNgroup有返回值
export const dev30_50fan = (pid) => {
    let mPids = ["1005", "1006", "1007"];
    return judgeContailPid(mPids, pid);
}
function judgeContailPid(mPids, pid) {
    for (let i = 0; i < mPids.length; i++) {
        if (mPids[i] == pid) {
            return true;
        }
    }
    return false;
}
//是否是rgb，在mqtt那个使用
export const isRGBDeviceset = (pid) => {
    if (isRGBDevice(pid)) {
        return '01';
    } else {
        return '00';
    }
}
//是否是dim，在mqtt那个使用
// export const isDimDeviceset = (pid) => {
//     if (isDimDevice(pid)) {
//         return '01';
//     } else {
//         return '00';
//     }
// }
